<%@ page import="kgc.NewsService.NewsService" %>
<%@ page import="kgc.NewsServiceImpl.NewsServiceImpl" %>
<%@ page import="kgc.pojo.News_Category" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.sql.Timestamp" %>
<%@ page import="kgc.pojo.News_User" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%
        int num = (int) session.getAttribute("num");
        NewsService service = null;
        if (num == 1){
            News_Category category = new News_Category();
            category.setName(request.getParameter("newsName"));
            category.setId(Integer.parseInt(request.getParameter("newsid")));
            String date = request.getParameter("date");
            category.setDate(new Date());
            service = new NewsServiceImpl();
            int rows = service.ServiceUpdateCategory(category);
            if (rows>0){
                response.sendRedirect(request.getContextPath()+"/index.jsp");
            }else {
                %>
                <div>修改失败!</div>
        <%
                }
            }else if (num == 2){
                News_User user = new News_User();
                user.setId(Integer.parseInt(request.getParameter("userid")));
                user.setUserName(request.getParameter("username"));
                user.setPassword(request.getParameter("password"));
                user.setEmail(request.getParameter("email"));
                user.setUserType(Integer.parseInt(request.getParameter("type")));
                service = new NewsServiceImpl();
                int rows = service.ServiceUpdateUser(user);
                if (rows>0){
                    response.sendRedirect(request.getContextPath()+"/index.jsp");
                }else {
                    %>
                    <div>修改失败!</div>
            <%
                    }
                }
            %>


</body>
</html>
